package tp.pr5.mv.instructions.jump;

import tp.pr5.mv.Instruction;
import tp.pr5.mv.Opcode;
import tp.pr5.mv.ProgramCounter;

public class RBT extends ConditionalJumps {
	
	
    public RBT() {
		
		op = Opcode.RBT;
	}
	
	public RBT ( int n ) {       // Constructor con parámetro (n).
		
		op = Opcode.RBT;
		this.n = n;
		
	}
	
	public void analyzeAndJump ( int a, ProgramCounter pc ) {
		
		if ( a != 0 ) {          // Si a NO es cero, se hace el salto relativo.
			int pci = pc.getPC();
			pc.setPC( pci + n - 1 );
		}
		
	}
	
	public Instruction create ( int par ) {
		return new RBT( par );
	}

}
